#ifndef __GLESSupport_H__
#define __GLESSupport_H__

#include "U2GLESPreRequest.h"
#include "U2ConfigOptionMap.h"
#include "U2GLESPixelUtil.h"
// #include "U2RenderWindow.h"
// #include "U2GLESPBuffer.h"


U2EG_NAMESPACE_BEGIN


class GLESRenderSystem;
// class U2GLESPBuffer;
class U2RenderWindow;


class _U2GLESShare U2GLESSupport
{
public:
    U2GLESSupport() { }
    virtual ~U2GLESSupport() { }

    /** Add any special config values to the system.
    Must have a "Full Screen" value that is a bool and a "Video Mode" value
    that is a string in the form of wxh.
    */
    virtual void addConfig() = 0;
    virtual void setConfigOption(const U2String &name, const U2String &value);

    /** Make sure all the extra options are valid
    @return string with error message
    */
    virtual U2String validateConfig() = 0;
    virtual U2ConfigOptionMap& getConfigOptions(void);

    virtual U2RenderWindow* createWindow(bool autoCreateWindow,
                                       GLESRenderSystem *renderSystem,
                                       const U2String& windowTitle) = 0;

    /// @copydoc RenderSystem::_createRenderWindow
    virtual U2RenderWindow* newWindow(const U2String &name,
                                    unsigned int width, unsigned int height,
                                    bool fullScreen,
                                    const NameValuePairList *miscParams = 0) = 0;

    /** Get vendor information. */
    const U2String& getGLVendor(void) const
    {
        return mVendor;
    }

    /** Get version information. */
    const U2String& getGLVersion(void) const
    {
        return mVersion;
    }

    /** Get the address of a function. */
    virtual void *getProcAddress(const U2String& procname) = 0;

    /** Initialises GL extensions, must be done AFTER the GL context has been
    established.
    */
    virtual void initialiseExtensions();

    /** Check if an extension is available. */
    virtual bool checkExtension(const U2String& ext) const;

    virtual unsigned int getDisplayMonitorCount() const
    {
        return 1;
    }

    /** Start anything special. */
    virtual void start() = 0;
    /** Stop anything special. */
    virtual void stop() = 0;

//    virtual U2GLESPBuffer *createPBuffer(PixelComponentType format, size_t width, size_t height) = 0;

private:
    U2String            mVersion;
    U2String            mVendor;

protected:
    /// Stored options
    U2ConfigOptionMap   mOptions;
    /// This contains the complete list of supported extensions
    std::set<U2String>  extensionList;
};


U2EG_NAMESPACE_END

#endif
